﻿using DRHotel_v1.Classes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections;
using DRHotel_v1.Classes.DBManagers;

namespace DRHotel_v1.HousekeepingAndStaffMngmt
{
    public partial class ItemManagementRetrievedFeedback : Form
    {
        public ItemManagementRetrievedFeedback(string Type, string Value)
        {
            InitializeComponent();

            //Defining what the user search by and get the results
            if (Type.Equals("Item ID"))
            {
                int value2 = Convert.ToInt32(Value);
                ArrayList itemList = HousekeepingDBManager.GetItemListByItemID(value2);

                int counter = 0;
                foreach (Item item in itemList)
                {
                    this.dgvResult.Rows.Add(new DataGridViewRowCollection(this.dgvResult));
                    this.dgvResult.Rows[counter].SetValues(item.itemID, item.itemName, item.itemPrice);
                    counter++;
                }
            }
            else if (Type.Equals("Item Name"))
            {
                ArrayList itemList = HousekeepingDBManager.GetItemListByItemName(Value);

                int counter = 0;
                foreach (Item item in itemList)
                {
                    this.dgvResult.Rows.Add(new DataGridViewRowCollection(this.dgvResult));
                    this.dgvResult.Rows[counter].SetValues(item.itemID, item.itemName, item.itemPrice);
                    counter++;
                }
            }
            else if (Type.Equals("All"))
            {
                ArrayList itemList = HousekeepingDBManager.GetAllItemList();

                int counter = 0;
                foreach (Item item in itemList)
                {
                    this.dgvResult.Rows.Add(new DataGridViewRowCollection(this.dgvResult));
                    this.dgvResult.Rows[counter].SetValues(item.itemID, item.itemName, item.itemPrice);
                    counter++;
                }
            }

        }
    }
}
